//
//  DetailView.m
//  Find
//
//  Created by lanou3g on 15/10/27.
//  Copyright © 2015年 Reiko. All rights reserved.
//

#import "DetailView.h"

@implementation DetailView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubviews];
    }
    return self;
}

#pragma mark -- 布局视图
- (void)addSubviews{
    self.backgroundColor = [UIColor whiteColor];
    // 用户图像
    self.mineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kDetailMineImageViewX, kDetailMineImageViewY, kDetailMineImageViewWidth, kDetailMineImageViewHeight)];
    self.mineImageView.backgroundColor = [UIColor orangeColor];
    self.mineImageView.layer.masksToBounds = YES;
    self.mineImageView.layer.cornerRadius = self.mineImageView.frame.size.width/2;
    [self addSubview:self.mineImageView];
    // 用户名
    self.userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.mineImageView.frame)+kDetailUserNameLabelToMineImageViewX, CGRectGetMinY(self.mineImageView.frame), kDetailUserNameLabelWidth, kDetailUserNameLabelHeight)];
    self.userNameLabel.textColor = kFindListCellLabelTextColor;
    self.userNameLabel.font = [UIFont boldSystemFontOfSize:kDetailLabelFont];
    [self addSubview:self.userNameLabel];
    // 线1(用户名跟标题之间的线)
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.userNameLabel.frame), CGRectGetMaxY(self.userNameLabel.frame)+(kDetailTitleLabelToUserNameLabelY-1)/2, CGRectGetWidth(self.userNameLabel.frame), 1)];
    view1.backgroundColor = kFindListCellLabelTextColor;
    [self addSubview:view1];
    
    
    // 标题
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.userNameLabel.frame), CGRectGetMaxY(self.userNameLabel.frame)+kDetailTitleLabelToUserNameLabelY, kDetailTitleLabelWidth, kDetailTitleLabelHeight)];
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont boldSystemFontOfSize:kDetailLabelFont];
    [self addSubview:self.titleLabel];
    
    // 线3(图片跟地点之间)
    UIView  *view3 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.mineImageView.frame), CGRectGetMaxY(self.mineImageView.frame)+(kDetailAddressLabelToDistanceLabelY-1)/2, kScreenWidth*0.936, 1)];
    view3.backgroundColor = kFindListCellLabelTextColor;
    [self addSubview:view3];
    
    
    
    
    // 地点
    UILabel *address = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.mineImageView.frame), CGRectGetMaxY(self.mineImageView.frame)+kDetailAddressLabelToDistanceLabelY, 40, kDetailAddressLabelHeight)];
    address.font = [UIFont systemFontOfSize:kDetailLabelFont];
    address.text = @"地点:";
    [self addSubview:address];
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(address.frame)+10, CGRectGetMinY(address.frame), kDetailAddressLabelWidth-50, kDetailAddressLabelHeight)];
    self.addressLabel.text = @"长宁区中山公园站附近";
    self.addressLabel.textColor = kFindListCellLabelTextColor;
    self.addressLabel.font = [UIFont systemFontOfSize:kDetailLabelFont];
    [self addSubview:self.addressLabel];
    // 时间
    UILabel *time = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(address.frame), CGRectGetMaxY(address.frame)+kDetailTimeLabelToAddressLabelY, 40, kDetailTimeLabelHeight)];
    time.font = [UIFont systemFontOfSize:kDetailLabelFont];
    time.text = @"时间:";
    [self addSubview:time];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(time.frame)+10, CGRectGetMinY(time.frame), kDetailTimeLabelWidth-50, kDetailTimeLabelHeight)];
    self.timeLabel.textColor = kFindListCellLabelTextColor;
    self.timeLabel.font = [UIFont systemFontOfSize:kDetailLabelFont];
    [self addSubview:self.timeLabel];
    
    
    // 备注
//    UILabel *distance = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(time.frame), CGRectGetMaxY(time.frame)+kDetailRemarkLabelToTimeLabelY, 40, kDetailRemarkLabelHeight)];
//    distance.font = [UIFont systemFontOfSize:kDetailLabelFont];
//    distance.text = @"距离:";
//    [self addSubview:distance];
//    self.distanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(distance.frame)+10, CGRectGetMinY(distance.frame), kDetailRemarkLabelWidth-50, kDetailRemarkLabelHeight)];
//    self.distanceLabel.text = @"1.5KM";
//    self.distanceLabel.font = [UIFont systemFontOfSize:kDetailLabelFont];
//    self.distanceLabel.textColor = kFindListCellLabelTextColor;
//    [self addSubview:self.distanceLabel];

    UILabel *distance = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(time.frame), CGRectGetMaxY(time.frame)+kDetailRemarkLabelToTimeLabelY, 40, kDetailRemarkLabelHeight)];
    distance.font = [UIFont systemFontOfSize:kDetailLabelFont];
    distance.text = @"距离:";
    [self addSubview:distance];
    self.distanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(distance.frame)+10, CGRectGetMinY(distance.frame), kDetailRemarkLabelWidth-50, kDetailRemarkLabelHeight)];
    self.distanceLabel.font = [UIFont systemFontOfSize:kDetailLabelFont];
    self.distanceLabel.textColor = kFindListCellLabelTextColor;
    [self addSubview:self.distanceLabel];

    // 线4(备注跟详细内容之间)
    UIView *view4 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(distance.frame), CGRectGetMaxY(distance.frame)+(kDetailDetailLabelToRemarkLabelY-1)/2, kScreenWidth*0.936, 1)];
    view4.backgroundColor = kFindListCellLabelTextColor;
    [self addSubview:view4];
    // 详细内容

//    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(distance.frame), CGRectGetMaxY(distance.frame)+kDetailDetailLabelToRemarkLabelY, kDetailDetailLabelWidth, kDetailDetailLabelHeight)];
  //  self.detailLabel.text = @"2014年11月25日下午6点左右,虹桥至长宁地铁2号线遗失一个钱包内含身份证,准考证,简历等个人近期内所需贵重物品,望知情者与136****联系,必有重谢!";

    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(distance.frame), CGRectGetMaxY(distance.frame)+kDetailDetailLabelToRemarkLabelY, kDetailDetailLabelWidth, kDetailDetailLabelHeight)];

    self.detailLabel.numberOfLines = 0;
    self.detailLabel.font = [UIFont systemFontOfSize:kDetailLabelFont];
    [self addSubview:self.detailLabel];
    // 收藏
    self.collectImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kDetailCollectImageX, CGRectGetMaxY(self.detailLabel.frame)+kDetailCollectImageToDetailLabelLY, kDetailCollectImageWidth, kDetailCollectImageHeight)];
    self.collectImageView.image = [UIImage imageNamed:@"iconfont-cellect-@3x"];
    // 开启点击事件
    self.collectImageView.userInteractionEnabled = YES;
    [self addSubview:self.collectImageView];
    // 收藏按钮
    self.collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.collectButton.frame = CGRectMake(CGRectGetMaxX(self.collectImageView.frame), CGRectGetMinY(self.collectImageView.frame), kDetailCollectButtonWidth, kDetailCollectButtonHeight);
   // self.collectButton.backgroundColor = [UIColor redColor];
    self.collectButton.userInteractionEnabled = YES;
    self.collectButton.titleLabel.font = [UIFont systemFontOfSize:kDetailButtonFont]; // button字体大小
    self.collectButton.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom; // button字体位置
    [self.collectButton setTitle:@"收藏" forState:UIControlStateNormal];
    [self.collectButton setTitleColor:kFindListCellLabelTextColor forState:UIControlStateNormal];
    [self addSubview:self.collectButton];
    
    // 收藏数量
    self.collectCountLabel = [[UILabel alloc] initWithFrame: CGRectMake(self.collectButton.right + 5,CGRectGetMinY(self.collectImageView.frame),kDetailCollectButtonWidth + 20,kDetailCollectButtonHeight)];
  //  self.collectCountLabel.backgroundColor = [UIColor grayColor];
    self.collectCountLabel.textColor = kFindListCellLabelTextColor;
    self.collectCountLabel.font = [UIFont systemFontOfSize:12];
    [self addSubview:self.collectCountLabel];
    // 转发
    /*
    self.transpondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.collectButton.frame)+kDetailButtonAndImageViewMargin, CGRectGetMinY(self.collectButton.frame), kDetailCollectImageWidth, kDetailCollectImageHeight)];
    self.transpondImageView.image = [UIImage imageNamed:@"iconfont-transpond-@3x"];
   // [self addSubview:self.transpondImageView];
    // 转发按钮
    self.transpondButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.transpondButton.frame = CGRectMake(CGRectGetMaxX(self.transpondImageView.frame), CGRectGetMinY(self.transpondImageView.frame), kDetailCollectButtonWidth, kDetailCollectButtonHeight);
    self.transpondButton.titleLabel.font = [UIFont systemFontOfSize:kDetailButtonFont];
    self.transpondButton.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
    [self.transpondButton setTitle:@"转发" forState:UIControlStateNormal];
    [self.transpondButton setTitleColor:kFindListCellLabelTextColor forState:UIControlStateNormal];
   // [self addSubview:self.transpondButton];
     
    // 更多
    self.moreImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.transpondButton.frame)+kDetailButtonAndImageViewMargin, CGRectGetMinY(self.transpondButton.frame), kDetailCollectImageWidth, kDetailCollectImageHeight)];
    self.moreImageView.image = [UIImage imageNamed:@"iconfont-more-@3x"];
   // [self addSubview:self.moreImageView];
    // 更多按钮
    self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.moreButton.frame = CGRectMake(CGRectGetMaxX(self.moreImageView.frame), CGRectGetMinY(self.moreImageView.frame), kDetailCollectButtonWidth, kDetailCollectButtonHeight);
    self.moreButton.titleLabel.font = [UIFont systemFontOfSize:kDetailButtonFont];
    self.moreButton.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
    [self.moreButton setTitle:@"更多" forState:UIControlStateNormal];
    [self.moreButton setTitleColor:kFindListCellLabelTextColor forState:UIControlStateNormal];
   // [self addSubview:self.moreButton];
     */
    // 线5(收藏按钮跟照片之间)
    UIView *view5 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.detailLabel.frame), CGRectGetMaxY(self.collectImageView.frame)+4, kScreenWidth*0.936, 1)];
    view5.backgroundColor = kFindListCellLabelTextColor;
    [self addSubview:view5];
    
    // 照片label
    self.pictureLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.detailLabel.frame), CGRectGetMaxY(self.collectImageView.frame)+kDetailPictureLabelToCollectImageViewY, kDetailPictureLabelWidth, kDetailPictureLabelHeight)];
    self.pictureLabel.text = @"照片";
    self.pictureLabel.font = [UIFont boldSystemFontOfSize:kDetailLabelFont];
//    self.pictureLabel.backgroundColor = [UIColor grayColor];
    [self addSubview:self.pictureLabel];
    // 下拉
    self.pulldownButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.pulldownButton.frame = CGRectMake(CGRectGetMaxX(self.pictureLabel.frame), CGRectGetMinY(self.pictureLabel.frame), kDetailPictureLabelHeight, kDetailPictureLabelHeight);
    [self.pulldownButton setImage:[UIImage imageNamed:@"iconfont-pulldown-@3x"] forState:UIControlStateNormal];
    [self addSubview:self.pulldownButton];
    // 相片
    self.photoBgView  = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.pictureLabel.frame)+kDetailOneImageViewToPictureLabelY, kScreenWidth, kDetailOneImageViewHeight)];
//    self.photoBgView.backgroundColor = [UIColor blackColor];
    [self addSubview:self.photoBgView];
    

    // 线6(照片跟评论之间的线)
    UIView *view6 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.photoBgView.frame), CGRectGetMaxY(self.photoBgView.frame)+(kDetailCommentLabelToOneImageViewY-1)/2, kScreenWidth*0.936, 1)];
    view6.backgroundColor = kFindListCellLabelTextColor;
    [self addSubview:view6];
    
    // 评论
    self.commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.photoBgView.frame), CGRectGetMaxY(self.photoBgView.frame)+kDetailCommentLabelToOneImageViewY, kDetailCommentLabelWidth, kDetailCommentLabelHeight)];
    self.commentLabel.font = [UIFont boldSystemFontOfSize:kDetailLabelFont];
    self.commentLabel.text = @"评论";
    [self addSubview:self.commentLabel];
    //
    self.commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.commentButton.frame = CGRectMake(CGRectGetMaxX(self.commentLabel.frame), CGRectGetMinY(self.commentLabel.frame), kDetailCommentLabelHeight, kDetailCommentLabelHeight);
    [self.commentButton setImage:[UIImage imageNamed:@"iconfont-pulldown-@3x"] forState:UIControlStateNormal];
    [self addSubview:self.commentButton];
    
}






/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
